<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
         var st = new Date();
    </script>
    <img  alt="测试图片" src="http://sp2.yokacdn.com/photos/f3/4f/702018/photo_322092_500.jpg"  onload="showspeed();">
        <div id='showtxt'></div>
        <script>
            // var arr=["网速低于50KB","网速在50-100KB之间","网速在100-200KB之间","网速在200-300KB之间","300以上"];
            function showspeed()  
            {  
                var filesize =35.4;//图片大小   
                var et = new Date();  
                console.log(et- st);
                var speed = Math.round(filesize*1000)/(et - st);
                document.title=speed;
                // var scope=(speed>0 && speed<=50)?0:(speed>50 && speed<=100)?1:(speed>=100 && speed<200)?2:(speed>=200 && speed<300)?3:4;
                // alert(scope)
                document.getElementById("showtxt").innerHTML = ("您的下载速度为：" +  speed.toFixed(2) + " (K/秒)")  
            }  
        </script>
</body>
</html>